package com.filetransfer.app.ui.upload;
import android.content.Context;
import android.net.Uri;

import java.io.InputStream;

import javax.annotation.Nullable;

import cn.hutool.core.lang.func.Func0;
import lombok.Data;
@Data
public class FileInfo {
    private final Uri uri;
    private final String fileName;
    private Func0<InputStream> createInputStreamFunc;
    @Nullable
    FileAdapter.FileViewHolder holder;
    public FileInfo(Context context, Uri uri) {
        this.uri = uri;
        this.fileName = FileHelper.getFileNameFromUri(context, uri);
        this.createInputStreamFunc = () -> FileHelper.getFileInputStreamForUri(context, uri);
    }
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        FileInfo fileItem = (FileInfo) obj;
        return uri.equals(fileItem.uri);
    }
    @Override
    public int hashCode() {
        return uri.hashCode();
    }
}
